<script setup>
import { ref } from "vue";
import { getNoticeListService, delNoticeListService } from "@/api/notice";
import { Delete } from "@element-plus/icons-vue";

const messages = ref([]);
const getmessages = async () => {
  const res = await getNoticeListService();
  console.log(res);
  messages.value = res.data.list;
};

getmessages()

const del=async (id)=>{
    await delNoticeListService(id);
    getmessages()
}

</script>

<template>
  <!-- <el-divider /> -->
  <el-card style="max-width: 100%">
    <template #header>
      <div class="card-header">
        <span><h3>消息通知</h3></span>
      </div>
    </template>
    <div v-for="item in messages" :key="item.noticeId" class="content">
      <div style="float: left; width: 90%">
        <p style="font-weight: bold">{{ item.type }}</p>
        <p>{{ item.content }}</p>
      </div>
      <div class="del">
        <el-popconfirm
          @confirm="del(item.noticeId)"
          title="确认删除此消息?"
        >
          <template #reference>
            <el-button style="align-items: center" :icon="Delete" circle />
          </template>
        </el-popconfirm>
      </div>
    </div>
  </el-card>
</template>

<style scoped>
.content {
  display: flex;
  /* width: px; */
  /* border: 1px solid #eeeaea; */
  /* background-color: rgb(240, 237, 236); */
}
.del {
  float: left;
  width: 10%;
  align-items: center;
  text-align: center;
  display: flex;
}
</style>

